import { GLTFLoader } from 'plugin/GLTFLoader.js'

class ModelLoader {
    constructor() {
        this.core = new GLTFLoader();
        this.data = []
    }

    async load() {
        
        let pl = []
        pl.push(new Promise(resolve => {
            this.core.load('models/tower.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/arm.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/塔吊立柱基础.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/塔吊立柱组件.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/塔吊吊臂中端2.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/塔吊吊臂开端2.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/塔吊吊臂末端2.glb', resolve)
        }))
        pl.push(new Promise(resolve => {
            this.core.load('models/小吊钩.glb', resolve)
        }))
        

        this.data = await Promise.all(pl)
    }

    getModel(index){
        console.log(this.data[index])
        return this.data[index].scene.clone();
    }
}

// 导出这个类
export {ModelLoader};